package com.atguigu.lease.web.app.context;

import com.atguigu.lease.model.entity.UserInfo;
import org.springframework.stereotype.Component;

@Component
public class LoginUserContext {
    private static final ThreadLocal<UserInfo> userThreadLocal = new ThreadLocal<>();
    public static void setUser(UserInfo userInfo){
        userThreadLocal.set(userInfo);
    }

    public static UserInfo getUser(){
        return userThreadLocal.get();
    }

    public static void clear(){
        userThreadLocal.remove();
    }
}
